<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <meta http-equiv="X-UA-Compatible" content="ie=edge">
  <title>Document</title>
  <link rel="styleSheet" href="./gc.spread.sheets.13.0.0.css" />
  <link rel="stylesheet" href="./gc.spread.sheets.excel2013white.13.0.0.css" />

  <script src="https://code.jquery.com/jquery-3.4.1.min.js"
    integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>

  <script src="./gc.spread.sheets.all.13.0.0.min.js" type="text/javascript">
  </script>

</head>

<body>
  <div id="ss" style="width:100%; height:360px;border: 1px solid gray;"></div>
  <div>1111</div>
  <script>
    window.onload = function () {
      var spread = new GC.Spread.Sheets.Workbook(document.getElementById("ss"), { sheetCount: 1 });
      initSpread(spread);
    };

    function initSpread(spread) {
      var sheet = spread.getSheet(0);

      sheet.setValue(1, 1, 'Press \'Add a Custom Function\' button');
      sheet.setColumnWidth(1, 225);
      sheet.setColumnWidth(2, 100);
      function FactorialFunction() {
        this.name = "FACTORIAL";
        this.maxArgs = 1;
        this.minArgs = 1;
      }
      FactorialFunction.prototype = new GC.Spread.CalcEngine.Functions.Function();
      FactorialFunction.prototype.evaluate = function (arg) {
        var result = 1;
        if (arguments.length === 1 && !isNaN(parseInt(arg))) {
          for (var i = 1; i <= arg; i++) {
            result = i * result;
          }
          return result;
        }
        return "#VALUE!";
      };
      var factorial = new FactorialFunction();

      sheet.setValue(3, 1, 'Formula');
      sheet.setValue(3, 2, '=factorial(5)');
      sheet.setValue(4, 1, 'Result');
      sheet.addCustomFunction(factorial);
      sheet.setFormula(4, 2, "=factorial(5)");

    };
  </script
</body>

</html>